@include("user.head")
	<!-- 公共头部 -->

	<div id="content_person">
	<div class="row">
		<div class="col-xs-3">
		@include('user.uc.navigation')
		</div>
		<div class="col-xs-9">
			<div class="panel panel-default">
				<div class="panel-heading">
					<h3 class="panel-title">编辑行业信息</h3>
				</div>
				<div class="panel-body">
					<form class="form-horizontal" id="Form" method="post" action="edit_industryinfo/update">
						<fieldset>
							<div class="form-group">
								<label class="col-xs-3 control-label no_padding_right">有无银行资信信息:</label>
								<div class="col-xs-6">
									<div class="radio">
										<label>
											<input name="has_bank_credit_info" id="" value="0" checked="" type="radio">
											无
										</label>
										<label>
											<input name="has_bank_credit_info" id="" value="1" type="radio">
											有
										</label>
									</div>
								</div>
							</div>

							@include("user.uc.template.bank_credit")

							<div class="form-group">
								<label for="inputEmail" class="col-xs-3 control-label no_padding_right">现有总资产:</label>
								<div class="col-xs-6">
									<input class="form-control input_size" name="total_capital" id="inputEmail" placeholder="" type="text">
								</div>
							</div>

							<div class="form-group">
								<label for="inputEmail" class="col-xs-3 control-label no_padding_right">净资产:</label>
								<div class="col-xs-6">
									<input class="form-control input_size" name="net_capital" id="inputEmail" placeholder="" type="text">
								</div>
							</div>

							<div class="form-group">
								<label for="inputEmail" class="col-xs-3 control-label no_padding_right">产业负债率:</label>
								<div class="col-xs-6">
									<input class="form-control input_size" name="liabilities_rate" autocomplete="of" id="inputEmail" placeholder="" type="text">
								</div>
							</div>

							<div class="form-group">
								<label for="textArea" class="col-xs-3 control-label label_size">需要说明的其他情况</label>
								<div class="col-xs-6">
									<textarea class="form-control text_size" rows="3" name="note" id="textArea"></textarea>
									<span class="help-block"></span>
								</div>
							</div>

							<div class="form-group">
								<div class="col-xs-12 text-center">
									<button type="button" id="sub" class="btn btn-primary ">保存修改</button>
								</div>
							</div>
						</fieldset>
					</form>
				</div>
			</div>
		</div>
	</div>
	</div>

	<!-- 公共底部 -->
	@include("user.footer")
	<!-- 公共底部 -->
	@include("user.common")
</body>
<script type="text/javascript">

$.get('edit_industryinfo/list', function(data){
	if(data.success){
		if(data.has_bank_credit_info ==1 )
		{
			$(".bank_credit").removeClass("hide");
		}

		$('input[name=has_bank_credit_info]').each(function(k, v){
			if($(this).val() == data.has_bank_credit_info){
				$(this).attr("checked", "checked");
			}
		})
		$('input[name=bank_credit_level]').val(data.bank_credit_level);
		$('input[name=bank_credit_copy]').val(data.bank_credit_copy);

		$('input[name=bank_card_code]').val(data.bank_card_code);
		$('input[name=total_capital]').val(data.total_capital);
		$('input[name=net_capital]').val(data.net_capital);
		$('input[name=liabilities_rate]').val(data.liabilities_rate);
		$('textarea[name=note]').val(data.note);
	}else{

	}
})


$('#bank_copy').AjaxFileUpload({
	path : "<% url('uc/user/upload') %>",
	onComplete : function(filename){
			$("#enwName").html(filename.filename);
			$("#fileName").val(filename.filename);
		}
	});



$("#sub").click(function(){
	var has_bank_credit_info = $("input[name='has_bank_credit_info']:checked").val().trim();
	var bank_credit_level = $("input[name='bank_credit_level']").val().trim();
	var bank_credit_copy = $("input[name='bank_credit_copy']").val().trim();
	var bank_card_code = $("input[name='bank_card_code']").val().trim();
	var total_capital = $("input[name='total_capital']").val().trim();
	var net_capital = $("input[name='net_capital']").val().trim();
	var liabilities_rate = $("input[name='liabilities_rate']").val().trim();
	var note = $("textarea[name='note']").val().trim();

	if(has_bank_credit_info == 0)
	{
		if (has_bank_credit_info == '' || total_capital == '' || net_capital == '' || liabilities_rate == '' )
		{
			warning('','必填信息不能为空');
			return false;
		}
	}
	else
	{
		if (has_bank_credit_info == '' || bank_credit_level == '' || bank_credit_copy == '' || bank_card_code == '' || total_capital == '' || net_capital == '' || liabilities_rate == '')
		{
			warning('','必填信息不能为空');
			return false;
		}
	}
	$.post("edit_industryinfo/update", {
	has_bank_credit_info : has_bank_credit_info,
	bank_credit_level : bank_credit_level,
	bank_credit_copy : bank_credit_copy,
	bank_card_code : bank_card_code,
	total_capital : total_capital,
	net_capital : net_capital,
	liabilities_rate : liabilities_rate,
	note : note
	},function (data){
		if(data.success){
			success("", "提交成功");
			setTimeout(function(){
				window.location.href="industryinfo";
			}, 2000)
		}else{
			warning("", data.msg);
		}
	})
})

$("input[type=radio]").bind("change", function(){
	var val = $(this).attr("value");
	if(val == 1){
		$(".bank_credit").removeClass("hide");
	}else{
		$('input[name=bank_credit_level]').val('');
		$('input[name=bank_credit_copy]').val('');
		$('input[name=bank_card_code]').val('');
		$("#enwName").html('');
		$(".bank_credit").addClass("hide");
	}
});


</script>
</html>